<?php
/**
 * Template Name: Listings - Landing
 * Description: The landing page for Listings
 *
 * @package ManterRealty
 * 
 */

get_header(); ?>
		
        <div class="listings_wrap clearfix">
        
        	<?php if ( have_posts() ) : ?>
            	<?php while ( have_posts() ) : the_post(); ?>
					<?php 
						the_content();
						
						$parent = url_to_postid($root.'/listings');
						$pages = get_pages('child_of='.$parent.'&parent='.$parent.'&sort_column=menu_order&sort_order=asc');
						
						?>
						<div class="listings_landing_item listings_landing_item_wide">
							<?php
								$vals = get_post_custom_values('image_sig',$page->ID);
								$imageSig = wp_get_attachment_image_src($vals[0], 'full');
								
								echo('<a href="'.$root.'/listings/signature-listings">');
									echo('<img src="'.$imageSig[0].'" alt="Signature Listings" />');
									echo('<span class="listings_landing_label">Signature Listings</span>');
								echo('</a>');
							?>
						</div>
						<div class="listings_landing_item">
							<?php
								$vals = get_post_custom_values('image_res',$page->ID);
								$imageRes = wp_get_attachment_image_src($vals[0], 'full');
								
								echo('<a href="'.$root.'/listings/residential-listings">');
									echo('<img src="'.$imageRes[0].'" alt="Residential Listings" />');
									echo('<span class="listings_landing_label">Residential Listings</span>');
								echo('</a>');
							?>
						</div>
						<div class="listings_landing_item">
							<?php
								$vals = get_post_custom_values('image_con',$page->ID);
								$imageCon = wp_get_attachment_image_src($vals[0], 'full');
								
								echo('<a href="'.$root.'/listings/new-construction-listings">');
									echo('<img src="'.$imageCon[0].'" alt="New Construction Listings" />');
									echo('<span class="listings_landing_label">New Construction Listings</span>');
								echo('</a>');
							?>
						</div>
						<div class="listings_landing_item">
							<?php
								$vals = get_post_custom_values('image_land',$page->ID);
								$imageLand = wp_get_attachment_image_src($vals[0], 'full');
								
								echo('<a href="'.$root.'/listings/land-listings">');
									echo('<img src="'.$imageLand[0].'" alt="Land Listings" />');
									echo('<span class="listings_landing_label">Land Listings</span>');
								echo('</a>');
							?>
						</div>
						<div class="listings_landing_item">
							<?php
								$vals = get_post_custom_values('image_mfi',$page->ID);
								$imageMFI = wp_get_attachment_image_src($vals[0], 'full');
								
								echo('<a href="'.$root.'/listings/mutli-family-investment-listings">');
									echo('<img src="'.$imageMFI[0].'" alt="Multi-Family &amp; Investment Listings" />');
									echo('<span class="listings_landing_label">Multi-Family &amp; Investment Listings</span>');
								echo('</a>');
							?>
						</div>
						
				<?php endwhile; 
			endif; ?>
			
            <?php /*if ( have_posts() ) :
					$args = array('category_name' => 'listings-landing','posts_per_page=5');
					$the_query = new WP_Query( $args );
					
					while ( $the_query->have_posts() ) : $the_query->the_post();
						$title = get_post_meta($post->ID,'Title',true);
						$background = get_post_meta($post->ID,'Image',true);
						$link = get_post_meta($post->ID,'URL',true);
						
						// pull the post tag out and assign it to a variable to be used as a class later
						$posttags = get_the_tags();
						$class = "";
						if ($posttags) {
						  foreach($posttags as $tag) {
							$class = $tag->name; 
						  }
						}
						echo('<div class="listings_landing_item listings_landing_'.$class.'">');
							echo('<a href="'.$root.$link.'">
									   <img src="'.$background.'" alt="'.$title.'" />
									   <span class="listings_landing_label">'.$title.'</span>
								   </a>');
							echo('</div>');
					endwhile; 
				endif; */?>
        </div>

<?php get_footer(); ?>